<template>
	<view class="">
		<u-navbar title="风险点" :placeholder="true" leftIconColor="#fff" @rightClick="openPopup" titleStyle="color: #fff"
			bgColor="#2172FC" :autoBack="true">
			<template #right>
				<u-icon name="hourglass" color="#fff" size="25"></u-icon>
			</template>
		</u-navbar>
	</view>
	<view class="p-10">
		<template v-if="list.length > 0">
			<view class="card" v-for="(item,index) in list" @click="goDetail(item.id)">
				<view class="flex m-between">
					<view class="name fw">
						{{item.riskLocationName}}
					</view>
					<view class="grade fw"> 隐患等级:{{item.hiddenLevelName}}
					</view>
				</view>
				<view class="des m-t-8 fw">
					<up-text :lines="1" :text="item.hiddenDangerInfo"></up-text>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post"> 危险因素: {{item.dangerPointName}}
					</view>
					<view class="pro"> 隐患状态: {{item.remark}}
					</view>
				</view>
				<view class="date m-t-8"> 限期日期：{{item.checkDate}}
				</view>
			</view>
		</template>
		<u-empty v-else mode="data">
		</u-empty>
	</view>
	<!-- 筛选popup -->
	<u-popup :show="showPopup" class="my-popup" :closeOnClickOverlay="true" mode="right" @close="closePopup">
		<view class="p-20">
			<my-forms ref="dynamicForm" :model="queryParams" :formItem="formData"></my-forms>
			<view class="flex m-between">
				<button type="error" size="mini" @click="reset">重置</button>
				<button type="primary" size="mini" @click="submit">确定</button>
			</view>
		</view>
	</u-popup>
	<u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
</template>
<script setup>
	import {
		reactive,
		ref
	} from "vue";
	import {
		onShow,
		onLoad
	} from '@dcloudio/uni-app'
	import {
		minPageFindHiddenDanger
	} from '@/api/hidden-danger.js'
	import useList from '@/hooks/useList.js'
	let dynamicForm = ref(null),
		queryParams = reactive({
			pageNum: 1,
			pageSize: 10,
			state: -1,
		}),
		formData = [{
			itemType: 'select',
			label: '隐患等级',
			type: 'hidden_danger_level',
			prop: 'hiddenLevel'
		}]

	onLoad((e) => {
		queryParams.riskLocationId = JSON.parse(e.riskLocationId)
	})

	const {
		getListData,
		list,
		scrollTop,
		showPopup,
		openPopup,
		closePopup,
		reset,
		submit
	} = useList({
		queryParams,
		api: {
			page: minPageFindHiddenDanger
		}
	})
	// 跳转详情
	const goDetail = (id) => {
		uni.navigateTo({
			url: '/pages/professional/secure/mapPageInfo?id=' + JSON.stringify(id)
		})
	}
	onShow(() => {
		getListData()
	})
</script>
<style lang="scss" scoped>
</style>